// backend/src/routes/systemRoutes.js
const systemMonitor = require("../modules/system-monitor/systemMonitor");

async function routes(fastify, options) {
  fastify.get("/api/system/info", async (request, reply) => {
    try {
      const info = await systemMonitor.getSystemInfo();
      reply.send({
        code: 200,
        status: "success",
        message: "System information retrieved successfully",
        data: info,
      });
    } catch (error) {
      fastify.log.error("Error fetching system info:", error);
      reply.status(500).send({
        code: 500,
        status: "error",
        message: "Internal Server Error",
        data: null,
      });
    }
  });
  // Add other system-related routes here
  fastify.get("/api/system/getGpuInfo", async (request, reply) => {
    try {
      const cpuUsage = await systemMonitor.getGpuInfo();
      reply.send({
        code: 200,
        status: "success",
        message: "GPU information retrieved successfully",
        data: cpuUsage,
      });
    } catch (error) {
      fastify.log.error("Error fetching CPU usage:", error);
    }
  });
}

module.exports = routes;
